<?php

namespace App\Admin\Controllers;

use App\Models\SportType;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class SportTypeController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'SportType';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new SportType());

        $grid->column('id', trans('admin.Id'));
        $grid->column('name', trans('admin.Name'));
        $grid->column('status', trans('admin.Status'));
        $grid->column('type', trans('admin.Type'));
        $grid->column('created_at', trans('admin.Created at'));
        $grid->column('updated_at', trans('admin.Updated at'));
        $grid->column('deleted_at', trans('admin.Deleted at'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(SportType::findOrFail($id));

        $show->field('id', trans('admin.Id'));
        $show->field('name', trans('admin.Name'));
        $show->field('status', trans('admin.Status'));
        $show->field('type', trans('admin.Type'));
        $show->field('created_at', trans('admin.Created at'));
        $show->field('updated_at', trans('admin.Updated at'));
        $show->field('deleted_at', trans('admin.Deleted at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new SportType());

        $form->text('name', trans('admin.Name'));
        $form->switch('status', trans('admin.Status'));
        $form->switch('type', trans('admin.Type'));

        return $form;
    }

    /**
     * Make a form select
     * 
     * @return array
     */
    public function list()
    {
        return SportType::select('id', 'name as text')->get()->toArray();
    }
}
